<!--
* @description:添加应付费用管理
* @fileName: NewExpensesPayable
* @author:石锦涛
* @date:2022-01-10
* @后台人员:石锦涛
-->
<template>
  <div>
    <!-- 新增应付费用 -->
    <el-row :span="1">
      <el-col :span="5">外协单位:</el-col>
      <el-col :span="10"
        ><el-input v-model="jieshu.TheOwnerUnitls"></el-input
      ></el-col>
    </el-row>
    <br />
    <el-row :span="1">
      <el-col :span="5">结算方式:</el-col>
      <el-col :span="12">
        <el-radio-group v-model="jieshu.ClearingForms">
          <el-radio label="微信支付">微信支付 </el-radio>
          <el-radio label="支付宝支付">支付宝支付</el-radio>
          <el-radio label="银联支付">银联支付 </el-radio>
          <el-radio label="企业转账">企业转账 </el-radio>
          <el-radio label="线下支付">线下支付 </el-radio>
          <el-radio label="其他">其他 </el-radio>
        </el-radio-group>
      </el-col>
    </el-row>
    <br />
    <el-row :span="1">
      <el-col :span="5">吨位(立方米):</el-col>
      <el-col :span="10"
        ><el-input v-model="jieshu.Tonnages"></el-input
      ></el-col>
    </el-row>
    <br />
    <el-row :span="1">
      <el-col :span="5">单价(元/立方米):</el-col>
      <el-col :span="10"
        ><el-input v-model="jieshu.UnitPrices"></el-input
      ></el-col>
    </el-row>
    <br />
    <el-row :span="1">
      <el-col :span="5">金额:</el-col>
      <el-col :span="10"><el-input v-model="jieshu.Moneycs"></el-input></el-col>
    </el-row>
    <br />
    <el-row :span="1">
      <el-col :span="5">业务日期:</el-col>
      <el-col :span="10"
        ><el-input type="Date" v-model="jieshu.BusinessTimes"></el-input
      ></el-col>
    </el-row>
    <br />
    <el-row :span="1">
      <el-col :span="5">经办人:</el-col>
      <el-col :span="10"
        ><el-input v-model="jieshu.ResponsiblePersonxs"></el-input
      ></el-col>
    </el-row>
    <br />
    <el-row :span="1">
      <el-col :span="5">备注:</el-col>
      <el-col :span="10"
        ><el-input type="textarea" v-model="jieshu.Remarkus"></el-input
      ></el-col>
    </el-row>
    <br />
    <el-row :span="1">
      <el-col :span="3"
        ><el-button @click="addjiashu()">提交</el-button></el-col
      >
      <el-col :span="1"><el-button @click="fanhui()">取消</el-button></el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      jieshu: {
        DusinessNumbers: "",
        TheOwnerUnitls: "",
        ClearingForms: "",
        Tonnages: "",
        UnitPrices: "",
        Moneycs: "",
        BusinessTimes: "",
        ResponsiblePersonxs: "",
        Remarkus: "",

        CheckStatets: "0",
        Collatoras: "1",

        IsDelete: "0",
      },
    };
  },
  methods: {
    //添加草稿
    addjiashu() {
      if (this.jieshu.TheOwnerUnitls.length === 0) {
        alert("货主单位不能为空");
        return;
      }
      if (this.jieshu.ClearingForms.length === 0) {
        alert("结算方式不能为空");
        return;
      }
      if (this.jieshu.Tonnages.length === 0) {
        alert("吨位不能为空");
        return;
      }
      var retNum = /^\d+(\.\d+)?$/; //匹配数字匹配数字(包括小数)/^\d*$/
      if (!retNum.test(this.jieshu.Tonnages)) {
        alert("吨位只能是正数,整数,小数");
        return;
      }
      if (this.jieshu.UnitPrices.length === 0) {
        alert("单价不能为空");
        return;
      }
      if (!retNum.test(this.jieshu.UnitPrices)) {
        alert("单价只能是正数,整数,小数");
        return;
      }
      if (this.jieshu.Moneycs.length === 0) {
        alert("金额不能为空");
        return;
      }
      if (!retNum.test(this.jieshu.Moneycs)) {
        alert("金额只能是正数,整数,小数");
        return;
      }
      if (this.jieshu.ResponsiblePersonxs.length === 0) {
        alert("经办人不能为空");
        return;
      }
      if (this.jieshu.Remarkus.length === 0) {
        alert("备注不能为空");
        return;
      }
      this.$axios
        .post(
          "https://localhost:44399/api/app/new-expen-app/new-expenses",
          this.jieshu
        )
        .then((res) => {
          if (res.data.Code > 0) {
            alert("添加成功");
            this.$router.push("/ExpensesPayableManagement");
          } else {
            alert("添加失败");
          }
        });
    },
    //返回管理
    fanhui() {
      this.$router.push("/ExpensesPayableManagement");
    },
  },
  created() {},
};
</script>

<style>
</style>